package com.etc.dao;

import com.etc.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
@Mapper
public interface UserMapper {
    int deleteByPrimaryKey(Integer userId);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Integer userId);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    List<User> selectByPage(int start, int limit, String content);

    int selectCount(String content);

    /**
     * 管理员登录校验
     *
     * @param user
     * @return
     */
    User selectByUser(User user);

    /**
     * 根据用户名查找用户
     *
     * @param userName
     * @return
     */
    User selectByUserName(String userName);

    /**
     * 根据手机号查找
     *
     * @param tel
     * @return
     */
    @Select("select * from user where tel = #{tel}")
    User selectByTel(String tel);

    /**
     * 根据邮箱查找
     *
     * @param email
     * @return
     */
    @Select("select * from user where email = #{email}")
    User selectByEmail(String email);

    /**
     * 普通用户登录校验
     */
    User checkByUser(User user);

    /**
     * 根据id 查找其他用户
     * @param user
     * @returnList
     */
    User getOtherUsers(User user);
    /**
     * 通过手机查找用户
     *
     * @param tel
     * @return
     */
    @Select("select * from user where tel = #{tel}")
    User getUserByTel(String tel);

    @Insert("insert into user (tel, level, status, udate) values" +
            "(#{tel}, #{level}, #{status}, #{uDate})")
    int insertByTel(User user);

    //前台用户注册
    int insertUser(User user);

    int updateStauts(int userId);
}